<?php

//Includes
require_once("MasterPage.php");
require_once("vcl/vcl.inc.php");
require_once("DB.php");
require_once("AdminLogin.php");
use_unit("comctrls.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class OrgDetail extends MasterPage
{
   public $lbHorizontalRule = null;
   public $lblReturn = null;
   public $lbDescription = null;
   public $lbSLURL = null;
   public $lbURL = null;
   public $lblOrgName = null;
   public $pnOrgDetail = null;
   public $lblCategory = null;
   public $lbCategory = null;
   public $lblSLURL = null;
   public $lblURL = null;
   public $lblOrgDescription = null;


   function personBeforeShow($sender, $params)
   {
      global $DB;

      //Get the unique ID for this organization
      if(!isset($_REQUEST['oid']))
      {
         $oid = GetSessionVar('oid');
      }
      else
      {
         $oid = $_REQUEST['oid'];
         SetSessionVar("oid", $oid);
      }

      if(!empty($oid))
      {

         // Populate public org info
         $query = "SELECT O.vchName as OrgName, O.vchDescription, O.vchURL, O.vchSLURL, O.category_iCategoryID AS iCategoryID, C.vchName AS vchCategory FROM org O INNER JOIN category C ON O.category_iCategoryID = C.iCategoryID  WHERE O.iOrgID = " . $oid;

         $DB->q_query->Close();
         $DB->q_query->SQL = $query;
         $DB->q_query->open();

         $this->lblOrgName->Caption = $DB->q_query->OrgName;

         $this->lblCategory->Caption = "<A HREF='Category.php?cid=" . $DB->q_query->iCategoryID . "'>" . $DB->q_query->vchCategory . "</A>";
         $this->lblOrgDescription->Caption = $DB->q_query->vchDescription;
         $this->lblURL->Caption = "<A HREF='" . $DB->q_query->vchURL . "'>" . $DB->q_query->vchURL . "</A>";
         $this->lblSLURL->Caption = "<A HREF='" . $DB->q_query->vchSLURL . "'>" . $DB->q_query->vchSLURL . "</A>";

         $DB->q_query->Close();

      }

      if(!isset($_REQUEST['src']))
      {
         $src = GetSessionVar('src');
      }
      else
      {
         $src = $_REQUEST['src'];
         SetSessionVar("src", $src);
      }

      if($src == "search")
        $this->lblReturn->Caption = "<A href='Search.php'>Return to search results</A>";
      else
        $this->lblReturn->Caption = "<A href='Category.php'>Return to category listing</A>";

   }

}

global $application;

global $OrgDetail;

//Creates the form
$OrgDetail = new OrgDetail($application);

//Read from resource file
$OrgDetail->loadResource(__FILE__);

//Shows the form
$OrgDetail->show();

?>